<?php
/**
 * Core_Model_Moduleaccesslevel
 * module access level model
 * 
 * @author Adrian Stolarski
 */
class Core_Model_Moduleaccesslevel implements Core_Model_Mainable {   
    
    /**
     *
     * @var type $module_data
     * module data handler
     */
    private $module_data_array = array();
    /**
     *
     * @var type $module_data
     * module data handler
     */
    private $module_data;
    /**
     *
     * @var type $user_access_level
     * user access level handler
     */
    private $user_access_level;
    /**
     *
     * @var type $redirect_action 
     * redirect action handler
     */
    public $redirect_action;
    
    /**
     * constructor()
     */
    public function __construct() {
        $this->module_data = new Core_Data_Moduledata;
        $this->user_access_level = new Core_Controller_Accesslevel;
        $this->redirect_action = new Login_Data_Loginredirect;
    }
    
    /**
     * main()
     * check user level and compare module access level
     * @param array $variables
     */
    public function main(array $variables = null) {
        $this->module_data_array = $this->module_data->main($variables['get']);
        $module_data = array();
        $module_data['module_access_level'] = $this->module_data_array['module_access_level'];
        $module_data['user_access_level'] = $this->module_data_array['user_access_level'];
        if($module_data['user_access_level'] < $module_data['module_access_level']){
            session_destroy();
            $this->redirect_action->main($variables);
        }
    }

}
